<!-- Buttons to add to the header. -->
<core-navbar-buttons slot="end">
    <ion-button *ngIf="!showLoading && glossary && glossary.browsemodes && glossary.browsemodes.length > 1" (click)="openModePicker($event)"
        [ariaLabel]="'addon.mod_glossary.browsemode' | translate">
        <ion-icon name="fas-sort" slot="icon-only" aria-hidden="true" />
    </ion-button>

    <ion-button *ngIf="!showLoading && glossary" (click)="toggleSearch()" [ariaLabel]="'addon.mod_glossary.bysearch' | translate">
        <ion-icon name="fas-magnifying-glass" slot="icon-only" aria-hidden="true" />
    </ion-button>

    @if (!courseContentsPage) {
    <ion-button fill="clear" (click)="openModuleSummary()" aria-haspopup="true" [ariaLabel]="'core.info' | translate">
        <ion-icon name="fas-circle-info" slot="icon-only" aria-hidden="true" />
    </ion-button>
    } @else {
    <core-context-menu>
        <core-context-menu-item [priority]="5000" [content]="'core.info' | translate" (action)="openModuleSummary()"
            iconAction="fas-circle-info" />
    </core-context-menu>
    }
</core-navbar-buttons>

<!-- Content. -->
<core-split-view>
    <ion-refresher slot="fixed" [disabled]="showLoading" (ionRefresh)="doRefresh($event.target)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}" />
    </ion-refresher>

    <core-search-box *ngIf="isSearch" (onSubmit)="search($event)" [placeholder]="'addon.mod_glossary.searchquery' | translate"
        [autoFocus]="true" [lengthCheck]="2" (onClear)="toggleSearch()" searchArea="AddonModGlossary-{{module.id}}" />

    <core-loading [hideUntil]="!showLoading" [message]="loadingMessage">
        <!-- Activity info. -->
        <core-course-module-info *ngIf="!isSearch" [module]="module" [description]="description" [component]="component"
            [componentId]="componentId" [courseId]="courseId" [hasDataToSync]="hasOffline" (completionChanged)="onCompletionChange()" />

        <ion-list *ngIf="!isSearch && entries && entries.offlineEntries.length > 0" class="addon-mod-glossary-index--offline-entries">
            <ion-item-divider>
                <ion-label>
                    <h2 class="big">{{ 'addon.mod_glossary.entriestobesynced' | translate }}</h2>
                </ion-label>
            </ion-item-divider>
            <ion-item *ngFor="let entry of entries.offlineEntries" (click)="entries.select(entry)" button [detail]="false"
                [attr.aria-current]="entries.getItemAriaCurrent(entry)">
                <ion-label>
                    <div class="addon-mod-glossary-index--offline-entry">
                        <ion-icon name="fas-clock" class="ion-margin-end" [attr.aria-label]="'core.notsent' | translate" />
                        <core-format-text [text]="entry.concept" contextLevel="module" [contextInstanceId]="glossary!.coursemodule"
                            [courseId]="courseId" />
                    </div>
                </ion-label>
            </ion-item>
        </ion-list>

        <ion-list *ngIf="entries && entries.onlineEntries.length > 0">
            <ng-container *ngFor="let entry of entries.onlineEntries; let index = index">
                <ion-item-divider *ngIf="getDivider && showDivider(entry, entries.onlineEntries[index - 1])">
                    <ion-label>
                        <h2 class="big">{{ getDivider!(entry) }}</h2>
                    </ion-label>
                </ion-item-divider>

                <ion-item button (click)="entries.select(entry)" [attr.aria-current]="entries.getItemAriaCurrent(entry)" [detail]="false">
                    <ion-label>
                        <core-format-text [text]="entry.concept" contextLevel="module" [contextInstanceId]="glossary!.coursemodule"
                            [courseId]="courseId" />
                    </ion-label>
                </ion-item>
            </ng-container>
        </ion-list>

        <core-empty-box *ngIf="(!entries || !entries.hasEntries) && (!isSearch || hasSearched)" icon="fas-list"
            [message]="'addon.mod_glossary.noentriesfound' | translate" [attr.role]="hasSearched ? 'alert' : null" />

        <core-infinite-loading [enabled]="entries && !entries.completed && (!isSearch || hasSearched)" [error]="loadMoreError"
            (action)="loadMoreEntries($event)" />
    </core-loading>

    <core-course-module-navigation collapsible-footer [hidden]="showLoading" [courseId]="courseId" [currentModuleId]="module.id" />

    <ion-fab slot="fixed" core-fab vertical="bottom" horizontal="end" *ngIf="canAdd && !showLoading">
        <ion-fab-button (click)="openNewEntry()" [attr.aria-label]="'addon.mod_glossary.addentry' | translate">
            <ion-icon name="fas-plus" aria-hidden="true" />
            <span class="sr-only">{{ 'addon.mod_glossary.addentry' | translate }}</span>
        </ion-fab-button>
    </ion-fab>
</core-split-view>
